import java.util.List;
import java.util.Stack;

public class Work01 {
    public static int[] reversePrint(ListNode head) {
        Stack list = new Stack();
        int[] res = new int[100];
        int i = 0;
        while(head != null){
            list.push(head.val);
            head = head.next;
        }
        while(!list.empty()){
            res[i] = (int)list.pop();
            i++;
        }
        return res;
    }

    public static void main(String[] args) {
        ListNode list = new ListNode(1);
        list.next = new ListNode(2);
        list.next.next = new ListNode(3);
        int[] ints = reversePrint(list);
    }
}
